import { UserEntity } from 'src/user/entities/user.entity';
import {
  Column,
  Entity,
  JoinColumn,
  ManyToOne,
  PrimaryGeneratedColumn,
} from 'typeorm';

@Entity('record_login')
export class RecordLoginEntity {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ length: 36, comment: '用户id' })
  user_id: string;

  @ManyToOne(() => UserEntity)
  @JoinColumn({ name: 'user_id' })
  user: UserEntity;

  @Column({ length: 256, comment: '登录ip' })
  ip: string;

  @Column({
    type: 'timestamp',
    default: () => 'CURRENT_TIMESTAMP',
    comment: '记录时间',
  })
  login_time: Date;
}
